package com.example.shop.goods.dao;

import com.example.shop.goods.dto.UserPurchasedGoods;
import com.example.shop.pojo.Goods;
import org.apache.ibatis.annotations.*;
import org.elasticsearch.client.ml.dataframe.evaluation.Evaluation;

@Mapper
public interface UserPurchasedGoodsDao {
    public static final String ALL_FIELDS_SQL = " o.goods_id,o.user_purchased_goods_class,o.user_purchased_number,o.user_buy_time ";

    @Results(id = "UserPurchasedGoodsDaoResultMap",value = {
            @Result(column = "goods_id",property = "goodsId"),
            @Result(column = "user_purchased_goods_class",property = "goodsClass"),
            @Result(column = "user_purchased_number",property = "userPurchasedNumber"),
            @Result(column = "user_buy_time",property = "userBuyTime")
    })
    @Select("select " + ALL_FIELDS_SQL +
            "from `order` o where order_id = ${orderId}")
    UserPurchasedGoods selectByOrderId(long orderId);

    @ResultMap("UserPurchasedGoodsDaoResultMap")
    @Select("select " + ALL_FIELDS_SQL +
            "from `order` o where order_id = ${orderId} and user_id = ${userId}")
    UserPurchasedGoods selectByIdAndUserId(@Param("orderId") long orderId,@Param("userId") long userId);

}
